<?php

namespace IMT\EventBundle\Entity;


use Doctrine\ORM\Mapping as ORM;
use IMT\EventBundle\Entity\BaseEvent;
use IMT\EventBundle\Models\EventInterface;
use IMT\EventBundle\Entity\File;
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;

/**
 * IMT\EventBundle\Entity\Event
 *
 * @ORM\Table(name="event")
 * @ORM\Entity
 */
class Event extends BaseEvent
{
	
// 	/**
// 	 * @var integer $id
// 	 *
// 	 * @ORM\Column(name="id", type="integer")
// 	 * @ORM\Id
// 	 * @ORM\GeneratedValue(strategy="AUTO")
// 	 * @Soap\ComplexType("int", nillable=true)
// 	 */
// 	protected $id;
      
    /**
     * @ORM\Column(type="integer")
     * @Soap\ComplexType("int", nillable=true)
     */
    protected $importance;
        
    /**
     * @ORM\OneToMany(targetEntity="IMT\Plugins\ParticipantsBundle\Entity\ParticipantEvent", mappedBy="event", cascade={"all"})
     */
    private $participants;


    public function __construct()
    {
    	parent::__construct();
    	
    	$this->participants = new \Doctrine\Common\Collections\ArrayCollection();
    }
    
    /**
     * {@inheritDoc}
     */
    public function convertEventToJson()
    {
    	$vars = get_object_vars($this);
    
    	foreach ($vars as $key => $value)
    	{
    		if(is_object($value)){
    			if(false === $value instanceof \DateTime)
    				unset($vars[$key]);
    		}
    	}
    	
    	return json_encode($vars);
    }
    
    /**
     * {@inheritDoc}
     */
    public function getId()
    {
    	return $this->id;
    }

    /**
     * Set importance
     *
     * @param integer $importance
     */
    public function setImportance($importance)
    {
        $this->importance = $importance;
    }

    /**
     * Get importance
     *
     * @return integer 
     */
    public function getImportance()
    {
        return $this->importance;
    }

    /**
     * Add participants
     *
     * @param IMT\Plugins\ParticipantsBundle\Entity\ParticipantEvent $participants
     */
    public function addParticipantEvent(\IMT\Plugins\ParticipantsBundle\Entity\ParticipantEvent $participants)
    {
        $this->participants[] = $participants;
    }

    /**
     * Get participants
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    public function getParticipants()
    {
        return $this->participants;
    }
}